package data;

import (
	"fmt"
	"database/sql"
	_"github.com/go-sql-driver/mysql"
	
)

//先安装go get u github.com/go-sql-driver/mysql


func Insert(url string,companyName string,industry string){
	db,err :=sql.Open("mysql","root:123456@tcp(localhost:3306)/crawler?charset=utf8")
	CheckErr(err)
	stmt,err :=db.Prepare("INSERT into jobinformation (Url,CompanyName,Industry) values (?,?,?)")
	CheckErr(err)
	res,err :=stmt.Exec(url,companyName,industry)
	CheckErr(err)
	fmt.Println(res.LastInsertId())
	
	
}

func CheckErr(err error){
	if err != nil {
		panic(err)
	}
}